import 'package:flutter/material.dart';
import 'package:flutter_application_1/index.dart';
import 'package:flutter_application_1/person.dart';

int tabIndex = 0;

List tabPages = [IndexPage(), PersonPage()];

class TabsState extends State<Tabs> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(title: Text('Widget.title')),
      body: tabPages[tabIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
          BottomNavigationBarItem(icon: Icon(Icons.people), label: '我的')
        ],
        onTap: (value) => {
          setState(() {
            tabIndex = value;
          })
        },
        currentIndex: tabIndex,
      ),
    );
  }
}

class Tabs extends StatefulWidget {
  Tabs({Key key}) : super(key: key);

  @override
  TabsState createState() {
    return TabsState();
  }
}
